/**
 * 导出入所题目
 * 
 * xingzheng/topics/export
 * 
 * 参数  year_id
 */

const Topics = require('../../../models/researchTopics')
const utils = require('../../../utils/index')
const $ = require('../../../utils/common')

const export_log = async function(req,res) {
    try{
      if (!'year_id' in req.query) {
        if (isNaN(req.query.year_id)) {
          $.sendMessage(res, 1015, '参数错误 yead_id')
          return
        }
        $.sendMessage(res, 1015, '参数错误 yead_id')
        return
      }

      const result = await Topics.findAndCountAll({
        where: {
          years: req.query.year_id
        },
        attributes: [
          'teacher_user_name', 'topic_name', 'topic_resource', 'research_direction', 'student_limit', 'topic_status', 'topic_background',
          'topic_work', 'requisite_skills', 'topic_remark', 'current_student', 'teacher_fullname', 'confirm_num', 'createdAt'
        ]
      })

      res.json({
        code: 200,
        result
      })
    }

    catch(error) {
        $.sendMessage(res, 0000, 'error' + error)
    }
}

module.exports = export_log